package com.ruoyi.system.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.BdmCloudInventory;
import com.ruoyi.system.domain.BdmCloudInventoryItem;
import com.ruoyi.system.domain.BdmOrderItem;
import com.ruoyi.system.domain.BdmUser;
import com.ruoyi.system.domain.dto.*;
import com.ruoyi.system.domain.vo.AgencyInventoryVo;
import com.ruoyi.system.domain.vo.BdmCloudInventoryItemVo;
import com.ruoyi.system.domain.vo.applet.AppletCloudInventoryVo;
import com.ruoyi.system.domain.vo.applet.CommodityDetailsVo;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 云库存Service接口
 *
 * @author ruoyi
 * @date 2024-12-24
 */
public interface IBdmCloudInventoryService extends IService<BdmCloudInventory>
{
    /**
     * 查询云库存
     *
     * @param id 云库存主键
     * @return 云库存
     */
    public BdmCloudInventory selectBdmCloudInventoryById(Long id);

    /**
     * 查询云库存列表
     *
     * @param bdmCloudInventory 云库存
     * @return 云库存集合
     */
    public List<BdmCloudInventory> selectBdmCloudInventoryList(BdmCloudInventory bdmCloudInventory);

    /**
     * 新增云库存
     *
     * @param bdmCloudInventory 云库存
     * @return 结果
     */
    public int insertBdmCloudInventory(BdmCloudInventory bdmCloudInventory);

    /**
     * 修改云库存
     *
     * @param bdmCloudInventory 云库存
     * @return 结果
     */
    public int updateBdmCloudInventory(BdmCloudInventory bdmCloudInventory);

    /**
     * 批量删除云库存
     *
     * @param ids 需要删除的云库存主键集合
     * @return 结果
     */
    public int deleteBdmCloudInventoryByIds(Long[] ids);

    /**
     * 删除云库存信息
     *
     * @param id 云库存主键
     * @return 结果
     */
    public int deleteBdmCloudInventoryById(Long id);


    /**
     * 增减库存   type   BdmCloudInventoryEnum.SUB.getType() 减库存    BdmCloudInventoryEnum.ADD.getType()  回库存
    */
    void addOrRollBackStock(List<BdmCloudInventoryItem> bdmCloudInventoryItems, Long type);

    //根据订单项添加云库存
    void addBdmCloudInventory(List<BdmOrderItem> bdmOrderItems, BdmUser bdmUser);

    /**
     * 根据 商品 和用户 信息  返回 云库存明细信息
     */
    void addBdmCloudInventoryItem(BdmCloudInventoryItem bdmCloudInventoryItemDto, BdmUser bdmUser);


    /**
     * 查询代理库存列表
     */
    List<AgencyInventoryVo> listAgencyInventory(BdmCloudInventoryDto bdmCloudInventoryDto);
    /**
     * 修改云库存
     */
    boolean modifiedInventory(BdmCloudInventoryEditDto bdmCloudInventoryEditDto);

    /**
     * 查询我的云库存列表
     */
    AppletCloudInventoryVo listByUser();

    /**
     * 查询代理库存详情
     */
    List<BdmCloudInventory> listAgencyInventoryById(Long userId);

    /**
     * 查询云库存明细
     */
    List<BdmCloudInventoryItem> listByCloudInventoryId(BdmCloudInventoryItemDto bdmCloudInventoryItemDto);


    /**
     *  后台查询云库存明细
     */
    List<BdmCloudInventoryItemVo> cloudInventoryDetail(CloudInventoryDetailDto cloudInventoryDetailDto);

    /**
     * 查询库存扣减类型
     */
    List<String> getInventoryDeductionType();

    /**
     *  云库存进货
     */
    boolean cloudInventoryPurchase(CloudInventoryPurchaseDto cloudInventoryPurchaseDto);

    /**
     * 补货查看商品详情
     */
    CommodityDetailsVo getCommodityDetails(Long goodId);


    /**
     * 云库存提货到线下
     */
    String cloudInventoryPickup(CloudInventoryPickupDto cloudInventoryPickupDto);

    /**
     * 云库存余额支付
     * @param orderId
     * @return
     */
    AjaxResult payCloudInventoryOrder(String orderId);

    /**
     * 云仓补货查询用户
     */
    SysUser getUser(Long userId);


    /**
     * 云仓配货
     */
    String cloudWarehouseReplenishment(BdmCloudReplenishmentDto dto);

    /**
     * 查询云库存代理商
     * @param dto
     * @return
     */
    AjaxResult listAgencyInventoryByUserId(BdmCloudInventoryDto dto);

    AjaxResult cloudInventory(BdmOrderDto bdmOrderDto);
}
